<template>
  <div class="container">
    <el-dialog title="题目审核" :visible="auditDialogFormVisible"  @close="closeAuditDialogFormVisible" @open="getAudit" class="auditDialog" width="30%">
      <el-form :model="auditForm">
        <el-form-item>
          <el-radio-group v-model="auditForm.chkState">
            <el-radio :label="1">通过</el-radio>
            <el-radio :label="2">拒绝</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item>
          <el-input type="textarea" placeholder=" 请输入审核意见" v-model="auditForm.chkRemarks"></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="closeAuditDialogFormVisible">取 消</el-button>
        <el-button type="primary" @click="confirmAudit">确 定</el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions.js'
// import { chkType } from '@/api/hmmm/constants.js'
export default {
  name: 'QuestionsCheck',
  props: {
    // 控制弹窗
    auditDialogFormVisible: {
      type: Boolean,
      default: false
    },
    auditId: {
      type: Number
    }
  },
  data () {
    return {
      // 审核表单数据
      auditForm: {
        chkState: undefined,
        chkRemarks: '',
        id: undefined
      }
      // chkType: chkType()
    }
  },
  methods: {
    // 关闭弹窗
    closeAuditDialogFormVisible () {
      this.$emit('closeAuditDialogFormVisible')
      // 清空审核表单数据
      this.auditForm = {
        chkState: undefined,
        chkRemarks: '',
        id: undefined
      }
    },
    // 打开弹窗时
    async getAudit () {
      // console.log(this.auditId)
      this.auditForm.id = this.auditId
    },
    // 点击确定
    async confirmAudit () {
      if (this.auditForm.chkRemarks.trim() === '') {
        this.$message.warning('请输入审核意见')
        return
      }
      const res = await choiceCheck(this.auditForm)
      console.log(res)
      // 刷新列表
      this.$emit('getquestCheckList')
      this.$message.success('操作成功')
      this.closeAuditDialogFormVisible()
      // this.auditForm = res.data
    }
  }
}
</script>

<style scoped lang="scss"></style>
